"""
Main frame.
This frame load three other frames:
- The upper part: CRC input
- The middle part: CRC choice
- The lower part: CRC calculation
"""

import tkinter as tk
from ui.InputFrame import *
from ui.PolynomialChoiceFrame import *
from ui.ResultFrame import *
from ui.CalculationDetailsFrame import *

class MainFrame(tk.Frame):
    """This frame contains all the user interactions needed for CRC
    calculations"""
    def update_input_frame(self):
        self.inputFrame.update()

    def create_widgets(self):
        """Create the frame starting layout."""
        self.inputFrame = CrcInputFrame(self)
        self.inputFrame.grid(column=0,row=0,sticky=tk.N+tk.S+tk.E+tk.W)
        
        self.polynomialChoiceFrame = CrcPolynomialChoiceFrame(self)
        self.polynomialChoiceFrame.grid(column=1,row=0,sticky=tk.N+tk.S+tk.E+tk.W)
        
        self.resultFrame = CrcResultFrame(self)
        self.resultFrame.grid(columnspan=2,row=2,sticky=tk.N+tk.S+tk.E+tk.W)

        self.calculationDetailsFrame = CrcCalculationDetailsFrame(self)
    def __init__(self,master=None):
        tk.Frame.__init__(self, master)
        self.parent = master
        self["relief"] = "raised"
        self["borderwidth"] = "2"
        self.rowconfigure(0, weight=3)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=1)
        self.create_widgets()
